﻿@{
    ViewBag.Title = "Home Page";
}

Lat: <span id="lat"></span>
<br />
Long: <span id="long"></span>

@section scripts {
    <script>
        $(function () {
            navigator.geolocation.getCurrentPosition(successCallback, errorCallback,
                {
                    enableHighAccuracy: true,
                    maximumAge: 1000,
                    timeout: 3333
                });
            function successCallback(position) {
                $("#lat").text(position.coords.latitude);
                $("#long").text(position.coords.longitude);
            }
            function errorCallback(error) {
                var errMsg = "";
                switch (error.code) {
                    case error.PERMISSION_DENIED:
                        errMsg = "User denied";
                        break;
                    case error.POSITION_UNAVAILABLE:
                        errMsg = "The current position could not be determined";
                        break;
                    case error.PERMISSION_DENIED_TIMEOUT:
                        errMsg = "Timeout occurred";
                        break;
                    default:
                        errMsg = error.toString();
                }
                alert(errMsg);
            }
        });
    </script>
}